//
//  HLBannerRequest.m
//  YueYue
//
//  Created by hulu001 on 2023/5/17.
//

#import "HLBannerRequest.h"

@implementation HLBannerRequest
{
    NSString *_code;
}

- (id)initWithType:(HLBannerPositionType)type
{
    self = [super init];
    
    if (self) {
        switch (type) {
            case HLBannerPositionTypeBanner:
                _code = @"me";
                break;
            case HLBannerPositionTypeSquare:
                _code = @"square";
                break;
        }
    }
    
    return self;
}

- (NSString *)requestUrl
{
    return @"/banner/list";
}

- (YTKRequestMethod)requestMethod
{
    return YTKRequestMethodGET;
}

- (id)requestArgument
{
    return @{@"positionCode":_code};
}

- (NSArray <HLBannerModel *> *)bannerList
{
    NSArray *lists = @[];
    
    NSArray *datas = [self.result valueForKey:@"data"];
    if (![datas isKindOfClass:[NSArray class]]){
        return lists;
    }
    
    if (datas.count > 0) {
       lists = [HLBannerModel mj_objectArrayWithKeyValuesArray:datas];
    }
    
    return lists;
}
@end
